<?php
namespace app\admin\controller;
use \think\Controller;
use \think\Db;
use \think\Loader;
class AuthRule extends Controller
{
    public function index()
    {
        //读取数据库中的权限分类以及其规则
        $data = Db::table('auth_rule t1')
        ->join('auth_cate t2','t1.cid = t2.cid')
        ->field('t1.*,t2.cname')
        ->paginate(5);
        // var_dump($data);
        // 取得控制器和其下的所有方法
        $cate = Db::table('auth_cate')->select();
        $controllers =  getControllers('../application/admin/controller');
        // $actionsAll = [];
        // foreach( $controllers as $key=>$value) {
        //     $actionsAll[$value] =  getActions('app\admin\controller\\' . $value);
        // }
        // $actionsAll=json_encode($actionsAll);
        // var_dump($controllers);
        // var_dump($actionsAll);
        // var_dump($cate);
        return $this->fetch('',['data'=>$data,'controllers'=>$controllers,'cate'=>$cate]);
    }

    public function actioncate()
    {
        $controller = input('controller');
        $actions = getActions('app\admin\controller\\' . $controller);
        return ['actions'=>$actions];
    }

    

}


?>